//
//  QuestionBankTypeViewController.m
//  jinnengExam
//
//  Created by mac on 2023/1/1.
//  Copyright © 2023 jznrj. All rights reserved.
//

#import "QuestionBankTypeViewController.h"
#import "PBFlatBarButtonItems.h"
#import "QuestionBankViewController.h"
@interface QuestionBankTypeViewController ()

@end

@implementation QuestionBankTypeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIBarButtonItem *back = [PBFlatBarButtonItems backBarButtonItemWithTarget:self selector:@selector(goBack)];
    [self.navigationItem setLeftBarButtonItem:back];
    self.title = @"题库选择";
    [self initView];
}


-(void) viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = NO;
    self.tabBarController.tabBar.frame = CGRectMake(0, 0, 0, 0);
    self.tabBarController.tabBar.hidden = YES;
}

-(void) initView{
   [self.view addSubview:self.jznWebView];
   [self.jznWebView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        if (@available(iOS 11.0, *)) {
            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
        } else {
            make.top.bottom.equalTo(self.view);
        }
    }];
    self.jznWebView.scrollView.bounces = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    [self.jznWebView loadLocalFile:@"/ios_jinneng/QuestionBankType" type:@"html"];
    
    [self registerFunction];
}
-(void) registerFunction{
    

//    [self.webViewBridge registerHandler:@"goBack" handler:^(id data, WVJBResponseCallback responseCallback) {
//        if (self.deep>1) {
//            [self findParentBankList];
//            return;
//        }
//        [self.navigationController popViewControllerAnimated:YES];
//    }];
    
    [self.webViewBridge registerHandler:@"toQuestion" handler:^(id data, WVJBResponseCallback responseCallback) {
        NSInteger questionBankId = [data[@"questionBankId"] intValue];
        QuestionBankViewController *vc = [[QuestionBankViewController alloc]init];
        vc.questionBankId = questionBankId;
        [self.navigationController pushViewController:vc animated:YES];
    }];
}


- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
}


-(void) goBack{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
